package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.OnlineHelpGuidanceRepository;
import org.example.petitionplatformsystem.dao.model.OnlineHelpGuidance;
import org.example.petitionplatformsystem.service.OnlineHelpGuidanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OnlineHelpGuidanceServiceImpl implements OnlineHelpGuidanceService {
    @Autowired
    private OnlineHelpGuidanceRepository onlineHelpGuidanceRepository;

    @Override
    public void addOnlineHelpGuidance(OnlineHelpGuidance onlineHelpGuidance) {
        onlineHelpGuidanceRepository.save(onlineHelpGuidance);
    }

    @Override
    public void updateOnlineHelpGuidance(OnlineHelpGuidance onlineHelpGuidance) {
        onlineHelpGuidanceRepository.save(onlineHelpGuidance);
    }

    @Override
    public void deleteOnlineHelpGuidance(OnlineHelpGuidance onlineHelpGuidance) {
        onlineHelpGuidanceRepository.delete(onlineHelpGuidance);
    }

    @Override
    public OnlineHelpGuidance getOnlineHelpGuidanceById(long id) {
        return onlineHelpGuidanceRepository.findById(id).orElse(null);
    }

    @Override
    public List<OnlineHelpGuidance> getAllOnlineHelpGuidances() {
        return onlineHelpGuidanceRepository.findAll();
    }
}
